package com.example.myactspringboot.controller;

import com.example.myactspringboot.bean.SysRole;
import com.example.myactspringboot.bean.SysUser;
import com.example.myactspringboot.server.RoleService;
import com.example.myactspringboot.server.SysUserService;
import com.example.myactspringboot.util.R2;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Create 2023-09-24 13:47
 * @Description
 */
@Controller
@RequestMapping("/user")
public class UserManageController {

    @Autowired
    private SysUserService service;

    @GetMapping("/toPage")
    public String toPage(){
        return "userManage";
    }

   @GetMapping("/getAllUser/{page}/{rows}")
    @ResponseBody
    public R2 getAllUser(@PathVariable int rows, @PathVariable int page){
        PageHelper.startPage(page,rows);
        List<SysUser> allUser = service.getAllUser();
        //数据，连续显示的页数
        PageInfo<SysUser> pageInfo = new PageInfo<>(allUser,5);
        return R2.ok().data(pageInfo);
    }

   /*  @PostMapping("delRole/{roleId}")
    @ResponseBody
    public R2 delRole(@PathVariable String roleId){
        int i = service.delRelevanceRole(roleId);
        return i>0?R2.ok().message("删除成功"):R2.error().message("删除失败");
    }*/

}
